﻿@model User
@using CP_SchoolForChildren_v0._1.Models.DataModel
@{
    ViewBag.Title = "Thông tin thành viên";

    var db = new CP_SchoolForChildren_v0._1.Models.DataModel.SFCEntities();
    Layout = "~/Views/Shared/FE/_Layout_FE_Index.cshtml";
    
}
<link href="@Url.Content("~/Content/FE/style/demo.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/FE/Addition.css")" rel="stylesheet" type="text/css" />
<div class="allhome" style="padding-top: 15px; height: 450px">
    <div class="content-main" style="width: 600px; float: left;">
        <div class="boxMod">
            <div class="content-header">
                <div class="tweet-user" style="border-bottom: 1px solid #E8E8E8;">
                    <h2 style="color:#774F38;">Thông tin thành viên</h2>
                </div>
                <div style="padding-top: 10px">
               
                    @{
                        if (User.Identity.Name != "")
                        {
                            string name = User.Identity.Name;
                            var user = from u in db.Users
                                       where (u.UserName == name)
                                       select u;
                            int userid = user.First().UserID;
                            var role = db.UserRoles.Single(ur => ur.RoleName == "Admin");
                            if ( userid == Model.UserID ||
                                 user.First().RoleID == role.RoleID)
                            { 
                                <div style="float: right; margin-right: 5px" id="edit-profile">
                                    @Html.ActionLink("Sửa thông tin", "Edit", new { id = Model.UserID })
                                </div>
                                <style type="text/css">
                                    #edit-profile a {
                                        color: #2C2C2C;
                                    }
                                    #edit-profile a:hover {
                                        color: #774F38;
                                    }
                                </style>
                            }
                        }
    
                    }
                </div>
                <div>
                    <div style="padding-left:15px; padding-right: 15px; float: left;">
                        <a>
                            <strong style="float: left; padding-bottom: 5px; font-size: 20px; color: #E08E79;">@Model.UserName</strong>
                            <br>
                            @if (string.IsNullOrEmpty(Model.AvatarURL))
                            {
                                Model.AvatarURL = @Url.Content("~/AvartarUser/default_avt.jpg");
                            }
                            <img src="@Model.AvatarURL" id="ProfileImage">
                        </a>
                    </div>                               
                    <div class="" style="float:left; width: 60%; padding-left: 10px; line-height: 25px">
                        <table>
                            <tr>
                                <td>Họ và tên</td>
                                <td>@Model.FullName</td>
                            </tr>
                            <tr>
                                <td>Email</td>
                                <td>@Model.Email</td>
                            </tr>
                            <tr>
                                <td>Giới tính</td>
                                <td>
                                    @if( Model.Gender.Equals("M"))
                                    {
                                        Model.Gender = "Nam";
                                    }
                                    else if(Model.Gender.Equals("F"))
                                    {
                                        Model.Gender = "Nữ";
                                    }
                                    else if (Model.Gender == "N/A")
                                    {
                                        Model.Gender = "Khác";
                                    }
                                    @Model.Gender
                                </td>
                            </tr>
                            <tr>
                                <td>Ngày sinh nhật</td>
                                <td>@Model.DOB.ToString("dd-MM-yyyy")</td>
                            </tr>
                            <tr>
                                <td>Chatting ID</td>
                                <td>@Model.ChattingID</td>
                            </tr>
                            <tr>
                                <td>Website Cá nhân</td>
                                <td>@Model.UserURL</td>
                            </tr>
                        </table>
                
                    </div>
                    <div style="clear: both"></div>
                </div>
        
            </div>
            <br class="spacer"/>
        </div>
        </div>
    <div class="dashboard" style="float: right;">
                <div class="content-header">
                    <div class="tweet-user" style="border-bottom: 1px solid #E8E8E8;">
                        <h2 style="color: #774F38">Các trường ưa thích</h2>
                    </div>
            <div class="header-inner">
                
                <br class="spacer"/>
                @{
                    List<FavoriteList> list = (from s in db.FavoriteLists
                                               where s.UserID == Model.UserID
                                               select s).ToList();
                    for (int i= list.Count; i >= list.Count -5; i--)
                    {
                        if (i >=1)
                        {
                            int schoolid = list[i - 1].SchoolID;
                            var school = (from s in db.Schools
                                         where s.SchoolID == schoolid
                                         select s).First();
                            <div style="padding: 10px;">
                                <a href='@Url.Action("Detail", "School", new { schoolID = schoolid })' >
                                    @school.SchoolName
                                </a>
                            </div>

                        }
                    }
                                         
                       }  
            </div>
    
        </div>
    </div>
</div>
